<?php
session_start();
?>

<?php
//Creating an array 
$id = $_SESSION['id'];
$i=0;


//Checking if the Design_note for this CR is already filled..
$con = mysql_connect("localhost","root","");
mysql_select_db("checklist", $con);
$check = "select * from design_note where id = '$id' ";
$result = mysql_query($check);
if(mysql_num_rows($result))
{
echo '<script type="text/javascript">','alert("Sorry , Design Note for this CR is already filled.");',
'window.location = "http://172.26.195.159/checklist/php/index.php";' ,'</script>';
}


else
{
$response = array();
$serial = array();

for ($i=1; $i<=6 ; $i++) {
$serial[] = $i;
$response[] = $_REQUEST['response'."".$i];
}

for ($i=0; $i<=5 ; $i++)
{

//creating a connection.
$con = mysql_connect("localhost","root","");

mysql_select_db("checklist", $con);

$sql = "insert into design_note(id ,serial , response) values('$id', '$serial[$i]' ,'$response[$i]')";

mysql_query($sql,$con) or die('Error: ' . mysql_error());
}


echo '<script type="text/javascript">','alert("Data inserted successfully !!");','</script>';
}  

?>


<html>
<form>
<input type="button" value="Close Window" onClick="window.close()">
</form>

</html>